package number_1433;

import java.util.Arrays;

public class Solution {
    public boolean checkIfCanBreak(String s1, String s2) {
        char[] charsS1 = s1.toCharArray();
        char[] charsS2 = s2.toCharArray();
        Arrays.sort(charsS1);
        Arrays.sort(charsS2);

        boolean leftBig = true;
        boolean rightBig = true;
        for (int i = 0; i < charsS1.length; i++) {
            if (charsS1[i] < charsS2[i]) {
                rightBig = false;
            } else if (charsS1[i] > charsS2[i]){
                leftBig = false;
            }
        }
        return leftBig || rightBig;
    }
}
